package com.yz.jdd.base.event;

import androidx.annotation.StringDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Created by shibin on 2017/1/5.
 */

public class Events<T> {
    /**
     * 各种事件code
     */
    //支付完成之后，回退到收银台，关闭之前页面
    public static final String PAY_COMPETE_TO_CLOSE = "pay_complete_to_close";
    public static final String PAY_WAITING_COUNTDOWN_FINISH = "pay_waiting_countdown_finish";
    //修改密码成功，关闭前边的验证界面
    public static final String EVENT_MODFIFYPSD_SUCCESS = "event_modifypsd_success";

    /**
     * 切换tab
     */
    public static final String EVENT_FRAGMENT_CHANGE="event_fragment_change";
    public static final String EVENT_HIDE_SHOW_BOTTOM_NAV="event_hide_show_bottom_nav";


    /**
     *  待办事件变动监听
     */
    public static final String EVENT_BACKLOG_CHANGE = "event_backlog_change";
    public static final String EVENT_BACKLOG_RESPONSE = "event_backlog_responese";

//    public static final String EVENT_DOWNLOAD_PATCH_FINISH = "event_download_patch_finish";//下载补丁文件成功
//    public static final String EVENT_CHECK_PATCH_FAILE = "event_check_patch_faile";//检测包错误
    //会员卡事件--------------------------------------------------
    public static final String EVENT_CARD_GET = "event_card_get";//会员卡办卡成功关闭事件
    public static final String EVENT_CARD_DETAIL_MAIN = "event_card_detail_main";//会员详情界面回到会员卡主页
    public static final String EVENT_CARD_DIALOG_PWD = "event_card_dialog_pwd";//设置密码成功后隐藏密码框
    public static final String EVENT_CARD_SCAN_FINISH = "event_card_scan_finish";//扫码成功后关闭界面
    //--------------------------------------------------------------
    //h5界面title获取事件
    public static final String EVENT_H5_RECEIVE_TITLE = "event_h5_receive_title";
    public static final String EVENT_H5_REFRESH = "event_h5_refresh";//刷新h5页面
    //-----------------------------------------------------------
    //302code 重新登录
    public static final String EVENT_302CODE = "event_302_code";

    //网络连接成功 执行设备登录
    public static final String EVENT_CONNECTION_SUCCESS = "event_connection_success";

    //权限设置成功 执行网络检查
    public static final String EVENT_PERMISSION_SUCCESS = "event_permission_success";


    //图片预览加载结果回调信息
    public static final String EVENT_IMAGEPREVIEW_RESULT = "event_imagepreview_result";
    public static final String EVENT_UPLOADPICTURE_RESULT = "event_uploadpicture_result";

    public static final String EVENT_LOAD_URL = "event_event_load_url";

    public static final String EVENT_VOICE_BROADCAT = "event_voice_broadcat";

    //下载APK进度监听监听
    public static final String EVENT_DOWNLOAD_PROGRESS = "event_download_progress";

    //扫码收款相关
    /**
     * 倒计时撤销收款
     */
    public static final String EVENT_CANCEL_PAY = "event_cancel_pay";

    /**
     * 付款码imageview
     */
    public static final String EVENT_INIT_QRCODEVIEW = "event_init_qrcodeview";

    /**
     * 付款码 已扫、已支付、支付失败
     */
    public static final String EVENT_QRCODE_PAY = "event_qrcode_pay";

    //事件枚举
    @StringDef({EVENT_DOWNLOAD_PROGRESS,PAY_COMPETE_TO_CLOSE, EVENT_CARD_GET, EVENT_H5_RECEIVE_TITLE,
            EVENT_MODFIFYPSD_SUCCESS,
            EVENT_CARD_DIALOG_PWD, EVENT_H5_REFRESH, EVENT_302CODE, EVENT_CARD_SCAN_FINISH,
            PAY_WAITING_COUNTDOWN_FINISH,
            EVENT_CONNECTION_SUCCESS,
            EVENT_IMAGEPREVIEW_RESULT,
            EVENT_UPLOADPICTURE_RESULT,
            EVENT_LOAD_URL,
            EVENT_VOICE_BROADCAT,
            EVENT_PERMISSION_SUCCESS,
            EVENT_BACKLOG_CHANGE,
            EVENT_FRAGMENT_CHANGE,
            EVENT_BACKLOG_RESPONSE,
            EVENT_CANCEL_PAY,
            EVENT_INIT_QRCODEVIEW,
            EVENT_QRCODE_PAY,
            EVENT_HIDE_SHOW_BOTTOM_NAV
           })

    @Retention(RetentionPolicy.SOURCE)
    public @interface EventCode {
    }


    public @Events.EventCode
    String code;
    public T content;

    public static <O> Events<O> setContent(O t) {
        Events<O> events = new Events<>();
        events.content = t;
        return events;
    }

    public <T> T getContent() {
        return (T) content;
    }
}
